package cn.house.dao;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Query;

import cn.house.entity.Users;

public class UsersDao extends BaseDao{
	public void save(Users users){
		currentSession().save(users);
	}
	
	public Users load(Serializable id){
		return (Users) HibernateUtil.currentSession().load(Users.class, id);
	}
	
	public void delete(Users user){
		currentSession().delete(user);
	}
	
	public Users update(Users user){
		return (Users) currentSession().merge(user);
	}
	
	public List<Users> findAll(){
		String sql="from Users";
		Query query = currentSession().createQuery(sql);
		return query.list();
	}
	
	public List<Users> findAll1(String username){
		String sql="from Users where username=:username";
		Query query = currentSession().createQuery(sql);
		query.setString("username", username);
		return query.list();
	}
}
